﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Diagnostics;
using EzDesk.MVVMBase;

namespace WPFTest
{
    /// <summary>
    /// Interaction logic for TestINotifyPropertyChanged.xaml
    /// </summary>
    public partial class TestINotifyPropertyChanged : Window
    {

        public TestINotifyMVVM vm = new TestINotifyMVVM { TestProperty = "superwolf" };
        public TestINotifyPropertyChanged()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(TestINotifyPropertyChanged_Loaded);
        }

        void TestINotifyPropertyChanged_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataContext = vm;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            vm.InternalClass.TestProperty = "fox";
        }
    }


    public class TestINotifyMVVM : ViewModelBase 
    {
        private TestINotifyClass internalClass = new TestINotifyClass();

        public TestINotifyClass InternalClass
        {
            get
            {
                return internalClass;
            }
        }

        public string TestProperty
        {
            get
            {
                return internalClass.TestProperty;
            }
            set
            {
                internalClass.TestProperty = value;
                RaisePropertyChanged("TestProperty");
            }
        }

    }

    public class TestINotifyClass:ViewModelBase
    {
        private string _testProperty;
        public string TestProperty
        {
            get
            {
                return _testProperty;
            }
            set
            {
                _testProperty = value;
                RaisePropertyChanged("TestProperty");
            }
        }
    }
}
